{% macro pagination_show(pagination, endpoint) %}
<nav aria-label="Page navigation">
    <ul class="pagination">
        {# 上一页 << #}
        <li {% if not pagination.has_prev %}class="disabled"{% endif %}>
            <a href="{% if pagination.has_prev %}{{ url_for(endpoint, page=pagination.prev_num, **kwargs) }}{% else %}#{% endif %}" aria-label="Previous">
                <span aria-hidden="true">&laquo;</span>
            </a>
        </li>

        {# 中间页码 #}
        {% for p in pagination.iter_pages() %}
            {% if p %}
                <li {% if p == pagination.page %}class="active"{% endif %}><a href="{{ url_for(endpoint, page=p, **kwargs) }}">{{ p }}</a></li>
            {% else %}
                {# 显示不完整时返回None，此时用...显示 #}
                <li><a href="#">&hellip;</a></li>
            {% endif %}
        {% endfor %}

        {# 下一页 >> #}
        <li {% if not pagination.has_next %}class="disabled"{% endif %}>
            <a href="{% if pagination.has_next %}{{ url_for(endpoint, page=pagination.next_num, **kwargs) }}{% else %}#{% endif %}" aria-label="Next">
                <span aria-hidden="true">&raquo;</span>
            </a>
        </li>
    </ul>
</nav>
{% endmacro %}